#ifndef  SHINY_BODY_HPP
# define SHINY_BODY_HPP

# include "world.hpp"
# include "../spriteanimate.hpp"
# include "fixture.hpp"

namespace Shiny
{
  namespace Applejack
  {
    class IA;

    class Body
    {
      friend class World;
      ~Body();
    public:
      Body(World&);
      void                 DeleteLater(void);

      void                 UpdateGraphics(void);
      void                 UpdateLogic(void);
      const std::string&   Name(void) const                           { return (_name);           }
      const SpriteAnimate& Sprite(void) const                         { return (_sprite);         }
      SpriteAnimate&       Sprite(void)                               { return (_sprite);         }
      const b2Body*        PhysicBody(void) const                     { return (_body);           }
      b2Body*              PhysicBody(void)                           { return (_body);           }
      b2Vec2               PhysicPoint(sf::Vector2f);
      Applejack::Fixture*  Fixture(const std::string& name);
      void                 SetName(const std::string& name)           { _name = name;             }
      bool                 operator==(const std::string& right) const { return (right == _name ); }
      void                 SetIA(const std::string& source, const std::string& type = "cpp");
      void                 SetIA(IA* script)                          { _script = script; }
      IA*                  GetIA(void)                                { return (_script);         }

      class Factory
      {
      public:
        static Body*       New(World&, Data);
        static Body*       New(World&, const std::string& type, sf::Vector2f pos, float angle = 0);
      };

    private:
      std::string   _name;
      World&        _world;
      b2Body*       _body;
      SpriteAnimate _sprite;
      IA*           _script;
    };
  }
}

#endif
